<?php

class BoletoService extends Model{

    /**
     * @var ClienteService
     */
    private $clienteService;

    public function injectDependencies() {
         $this->clienteService = ClienteService::getInstance();
    }

    public function findBilletByRelease($IDCobranca){
        $Cliente = $this->clienteService->findByPayment($IDCobranca);

        $Boleto = new Boleto($Cliente);

        $Boleto->setBank(BILLET_BANK);
        $Boleto->setPrice( $Cliente->getLancamentoById($IDCobranca)->getFoValor() );
        $Boleto->setProcessingDate( $Cliente->getLancamentoById($IDCobranca)->getDtData() );
        $Boleto->setMaturity( addDayIntoDate($Cliente->getLancamentoById($IDCobranca)->getDtData(), BILLET_MAX_EXPIRATION) );
        $Boleto->setAgency( BILLET_AGENCY );
        $Boleto->setTransferorCode( BILLET_TRANSFEROR_CODE );
        $Boleto->setBankCode( BILLET_BANK_CODE );
        $Boleto->setOurNumber( BILLET_OUR_NUMBER );
        $Boleto->setInstructions( BILLET_INSTRUCTIONS );
        $Boleto->setPaymentLocal( BILLET_PAYMENT_LOCAL );
        $Boleto->setTransferor( BILLET_TRANSFEROR );
        $Boleto->setWallet( BILLET_WALLET );
//        $Boleto->setDigitableLine( 'valorQualquer' );
        $Boleto->generateDigitableLine( BILLET_RANGE_DIGITABLE_LINE );

        return $Boleto;
    }

}

?>
